package org.jash.learnmvp;

import android.os.Bundle;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.viewpager2.widget.ViewPager2;

import com.google.android.material.tabs.TabLayout;
import com.google.android.material.tabs.TabLayoutMediator;

public class WeChatActivity extends AppCompatActivity {
    private TabLayout tab;
    private ViewPager2 pager;
    private MainAdapter adapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_we_chat);
        pager = findViewById(R.id.pager);
        tab = findViewById(R.id.tab);
        adapter = new MainAdapter(this);
        pager.setAdapter(adapter);
        new TabLayoutMediator(tab, pager, (t, p) -> {
            switch (p) {
                case 0:
                    t.setText("畅聊");
                    t.setIcon(R.drawable.ic_chat);
                    break;
                case 1:
                    t.setText("通信录");
                    t.setIcon(R.drawable.ic_group);
                    break;
                case 2:
                    t.setText("发现");
                    t.setIcon(R.drawable.ic_newspaper);
                    break;
                case 3:
                    t.setText("我的");
                    t.setIcon(R.drawable.ic_person);
                    break;
            }
        }).attach();
    }
}